package com.bw.zg3park2212.adpter

import android.widget.TextView
import com.bw.base.entity.DeviceEntityItem
import com.bw.zg3park2212.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class DeviceAdpter:BaseQuickAdapter<DeviceEntityItem,BaseViewHolder>(R.layout.item_device){
    override fun convert(helper: BaseViewHolder, item: DeviceEntityItem) {
        helper.setText(R.id.device_name,"项目名称/设备名称"+item.deviceName)
        helper.setText(R.id.device_type,"设备类型:"+item.deviceType)
        helper.setText(R.id.device_addres,"安装地点:"+item.installationLocation)
        helper.setText(R.id.device_count,"故障率:"+(item.failureRate*100)+"%")
        val device_stause = helper.getView<TextView>(R.id.device_stause)
        if (item.status=="故障"){
            device_stause.setTextColor(helper.itemView.context.getColor(R.color.color_weihu))
            device_stause.setBackgroundResource(R.drawable.bg_weihu)
            device_stause.text="故障"
        }else{
            device_stause.setTextColor(helper.itemView.context.getColor(R.color.color_kongxian))
            device_stause.setBackgroundResource(R.drawable.bg_kongxian)
            device_stause.text="正常"
        }
    }
}